package net.chrisrichardson.cloudtools.maven.plugins;

import java.io.File;

import net.chrisrichardson.ec2deployer.cluster.ClusterManager;
import net.chrisrichardson.ec2deployer.core.AWSProperties;

import org.apache.maven.plugin.AbstractMojo;

public abstract class AbstractCloudToolsMojo extends AbstractMojo {

  /**
   * Location of the AWS properties file.
   * 
   * @parameter expression="${cloudtools.aws.properties}"
   * @required
   */
  protected File awsPropertiesFile;

  /**
   * The name of the cluster to manage
   * @parameter expression="${cloudtools.cluster.name}"
   * 
   */
  protected String clusterName = "maven-cluster";
  
  public AbstractCloudToolsMojo() {
    super();
  }

  protected AWSProperties makeAWSProperties() {
    AWSProperties awsProperties = new AWSProperties(
        awsPropertiesFile.getAbsolutePath()); // TODO - define constructor to support File
    return awsProperties;
  }

    protected ClusterManager makeClusterManager() {
    ClusterManager manager = new ClusterManager(makeAWSProperties());
    ClusterManager.setReuseRunningInstancesForDebugging(true); // FIXME
    return manager;
  }

  protected String getClusterName() {
    return clusterName;
  }

}